﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AMing.Mvc4.Web
{
    public static class HostNameData
    {
        /// <summary>
        /// 初始化静态数据
        /// </summary>
        static HostNameData()
        {
            List = new Dictionary<HostNameEnum, string>();
            List.Add(HostNameEnum._debug, "localhost:24430");
            List.Add(HostNameEnum._default, "www.y2443.com");
            List.Add(HostNameEnum.soft, "soft.y2443.com");
            List.Add(HostNameEnum.moepet, "moepet.y2443.com");
            List.Add(HostNameEnum.test1, "test1.y2443.com");
            List.Add(HostNameEnum.img, "img.y2443.com");
            
            ViewList = new Dictionary<HostNameEnum, string>();
            ViewList.Add(HostNameEnum._debug, "~/Views/Default/");
            ViewList.Add(HostNameEnum._default, "~/Views/Default/");
            ViewList.Add(HostNameEnum.soft, "~/Views/Soft/");
            ViewList.Add(HostNameEnum.moepet, "~/Views/Moepet/");
            ViewList.Add(HostNameEnum.test1, "~/Views/Test1/");
            ViewList.Add(HostNameEnum.img, "~/Views/Img/");

#if DEBUG
            HostNameEnum debughostname = HostNameEnum._default;

            List[debughostname] = List[HostNameEnum._debug];
            ViewList[HostNameEnum._debug] = ViewList[debughostname];
#endif
        }

        /// <summary>
        /// 主机名列表
        /// </summary>
        public static Dictionary<HostNameEnum, string> List { get; set; }

        /// <summary>
        /// 主机名View列表
        /// </summary>
        public static Dictionary<HostNameEnum, string> ViewList { get; set; }

        /// <summary>
        /// 获取对应的主机名
        /// </summary>
        /// <param name="hostname"></param>
        /// <returns></returns>
        public static string GetHostName(HostNameEnum hostname)
        {
            if (HostNameData.List.ContainsKey(hostname))
            {
                return HostNameData.List[hostname];
            }
            return null;
        }
    }
}
